﻿Public Class Productos
    Inherits System.Web.UI.Page
    Dim c As New Conexion
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Session("VariableNombre") = Nothing Then
            Label1.Text = "Tienes que Logearte"
            btnLogout.Visible = False
        Else
            HyperLink1.Visible = False
            Label2.Text = "Bienvenido " + Session("VariableNombre").ToString()

            c.SeleccionarLetras(TextBox6, "select nombres from usuarios where login='" & Session("VariableNombre").ToString() & "'")
            Label2.Text = "Bienvenido " + TextBox6.Text


        End If

        If Not Page.IsPostBack Then
            'Llenamos el DropDownList
            DropDownList1.DataSource = c.IdProductos.Tables(0)

            DropDownList1.DataTextField = "descripcion"
            DropDownList1.DataBind()
            GridView1.DataBind()

            'Llenamos el Datagrid
            GridView1.DataSource = c.TablaProductos(DropDownList1.SelectedItem.Text)

            GridView1.DataBind()

        End If
    End Sub



    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles DropDownList1.SelectedIndexChanged
        GridView1.DataSource = c.TablaProductos(DropDownList1.SelectedItem.Text)
        GridView1.DataBind()
    End Sub

    Protected Sub btnLogout_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnLogout.Click
        Session("VariableNombre") = Nothing
        Response.Redirect("InicioSesion.aspx")
    End Sub

    
End Class